package data_structures;

/**
 * Represents (configuration, accuracy) pairs.
 * 
 * For example, if the 10-fold CV accuracy of 14-NN classifier is 90%, then it
 * will be represented by (14,0.9). It is useful for keeping configurations
 * sorted inside the heap (priority queue).
 */
public class ConfigurationAccuracyPair implements
		Comparable<ConfigurationAccuracyPair> {
	private HPConfiguration conf;
	private double accuracy;

	/**
	 * @param conf
	 *            Hyper-parameter configuration.
	 * @param accuracy
	 *            Accuracy of the configuration.
	 */
	public ConfigurationAccuracyPair(HPConfiguration conf, double accuracy) {
		this.conf = conf;
		this.accuracy = accuracy;
	}

	@Override
	public int compareTo(ConfigurationAccuracyPair o) {
		if (this.accuracy < o.getAccuracy()) {
			return -1;
		} else if (this.accuracy == o.getAccuracy()) {
			return 0;
		} else {
			return 1;
		}
	}

	/**
	 * @return the Hyper-parameter configuration.
	 */
	public HPConfiguration getConf() {
		return conf;
	}

	/**
	 * @return the accuracy
	 */
	public double getAccuracy() {
		return accuracy;
	}

	public String toString() {
		String str = conf.toString() + " --- Accuracy = "
				+ Double.toString(accuracy);
		return str;
	}

}
